package cn.yunhe.sao.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class UserAop {
	public static final String edp = "execution(* cn.yunhe.sao.service.UserServiceImpl.*(..))";
	
	@Before(edp)
	public void beforeprint(){
		System.out.println("user....doing qian:");
	}
	@After(edp)
	public void afterpprint(){
		System.out.println("user....doing hou:");
	}
	
	@Pointcut(edp)
	public void declareJ(){
		
	}
	
	
	@AfterThrowing(value="declareJ()",throwing="e")
	public void afterThrowing(JoinPoint jp,Exception e) throws Exception{
		System.out.println("e:"+jp.getSignature().getName());
		//System.out.println("e:属性:"+e.getMessage()+e.getLocalizedMessage()+e.toString());
		throw e;
	}
	
	@Pointcut("execution(* cn.yunhe.sao.service.UserServiceImpl.*Return(..))")
	public void ddd(){
		
	}
	
	@AfterReturning(value="ddd()",returning="result")
	public void afterReturning(JoinPoint jp,Object result){
		String methodName = jp.getSignature().getName();
		System.out.println("the method:"+ methodName + "return result:"+result);
	}
	
}
